package com.company.finance.ddd.domain.core.bill.repository;

import com.company.finance.ddd.common.IRepository;
import com.company.finance.ddd.domain.core.bill.aggregate.PurchaseItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.*;

@Repository
public class PurchaseItemRepository implements IRepository<PurchaseItem> {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public void save(PurchaseItem entity) {

    }

    @Override
    public List<PurchaseItem> query(Map<String, Object> queryCondition) {
        return jdbcTemplate.query("select * from bill_item_purchase where bill_id = ?"
                , queryCondition.values().toArray(), new BeanPropertyRowMapper<>(PurchaseItem.class));
    }

    @Override
    public PurchaseItem get(Long id) {
        return null;
    }

    @Override
    public void delete(Long billId) {
        throw new UnsupportedOperationException();
    }
}
